package com.prs.crm.dao.oa.impl;

import java.util.ArrayList;
import java.util.Collection;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.dao.oa.MyMailListTypeDao;
import com.prs.crm.domain.hr.Person;
import com.prs.crm.domain.oa.MyMailList;
import com.prs.crm.domain.oa.MyMailListType;

public class MyMailListTypeDaoImpl extends BaseDaoImpl<MyMailListType> implements MyMailListTypeDao{

	@Override
	public MyMailListType getTypeByTitle(String title,Person person) {
		// TODO Auto-generated method stub
		Criteria criteria = this.getSession().createCriteria(MyMailListType.class);
		criteria.add(Restrictions.eq("title", title));
		criteria.add(Restrictions.eq("person", person));
		ArrayList<MyMailListType> list = (ArrayList<MyMailListType>)criteria.list();
		if(list.size() == 0){
			return null;
		}else{
			return list.get(0);
		}
	}

}
